home *** CD-ROM | disk | FTP | other *** search
- /*
- This C module can be modified to suit your needs just make sure the
- initialization routine puts the code segment and end of code address in
- the request header during initialization.
- */
-
- #define ENDCODE 0x05c2 /* address of end of last segment, can be found by */
- /* linking the modules and then checking the map file */
-
- typedef unsigned char Byte;
- typedef unsigned int Word;
- typedef struct {
- Byte length; /* length of request header */
- Byte unit; /* unit code for block devices */
- Byte command; /* command code sent by DOS */
- Word status; /* status returned from driver code */
- char reserved[8]; /* reserved by DOS */
- char data; /* data from this point is variable */
- Word endcode; /* address of end of code needed by init routine */
- Word segment; /* code segment of driver */
- } RequestHeader;
-
-
- int handler(RequestHeader far *rh)
- {
- char *message = "Device Driver Loading...\n\r\007$";
- Word segment;
-
- asm mov ax,DGROUP /* get data segment of this module */
- asm mov ds,ax /* you only need this if you are going to use inline */
- /* code and reference local data */
-
- if(rh->command == 0) /* initialize */
- {
- /*
- you must put the code segment and end of code address into the
- request header when initializing, this is so DOS knows where to
- start loading the next device driver
- */
- asm mov segment,cs
- rh->endcode = ENDCODE;
- rh->segment = segment;
-
- asm mov ah,09h /* the initialization routine is the only */
- asm mov dx,message /* place you can safely call a DOS function */
- asm int 21h /* since we're not in the kernel yet */
-
- return 0;
- }
-
- /*
- you can call library functions that don't call DOS and don't need the C
- startup code, just remember to link using the correct memory model
-
- check the DOS programmers ref. for additional commands which DOS might
- pass to the device driver, if you don't have a DOS ref. send me mail and
- I'll upload a list of available commands
- */
- sound(10000);
- delay(50);
- sound(20000);
- delay(20);
- nosound();
-
- return 0;
-
- }
-